package com.cityeye.form;

import java.sql.Timestamp;

import org.apache.struts.upload.FormFile;

import com.cityeye.dao.DepartmentDao;
import com.cityeye.dao.PatrolDao;
import com.cityeye.dao.SubissuetypeDao;
import com.cityeye.entity.Department;
import com.cityeye.entity.Mmessage;
import com.cityeye.entity.Patrol;
import com.cityeye.entity.Subissuetype;

public class MmessageForm extends AbsEntityForm<Mmessage> {
	
	private Integer id;
	private String no;	
	private Integer subissuetypeId;
	private Integer patrolId;
	private Integer departmentId;
	private Integer quConfirmed=0;
	private String sender;
	private Integer msgtype=0;
	private String msgtitle;
	private String msgattachfiles;
	private Timestamp arrivetime;
	private Timestamp completetime;	
	private Integer msgstate=0;
	private String shiComments;
	private String quComments;
	private String jieComments;
	private String submitfiles;
	private String finalcomments;
	private Integer completestate=0;

	private Integer quDepartmentId;	
	private Integer problemJDId;	
	
	public Integer getProblemJDId() {
		return problemJDId;
	}

	public void setProblemJDId(Integer problemJDId) {
		this.problemJDId = problemJDId;
	}

	private FormFile img;
	
	public FormFile getImg() {
		return img;
	}

	public void setImg(FormFile img) {
		this.img = img;
	}

	// Property accessors
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}
	

	public String getNo() {
		return no;
	}

	public void setNo(String number) {
		this.no = number;
	}	

	public Integer getSubissuetypeId() {
		return this.subissuetypeId;
	}

	public void setSubissuetypeId(Integer subissuetype) {
		this.subissuetypeId = subissuetype;
	}

	public Integer getPatrolId() {
		return this.patrolId;
	}

	public void setPatrolId(Integer patrol) {
		this.patrolId = patrol;
	}

	public Integer getDepartmentId() {
		return this.departmentId;
	}

	public void setDepartmentId(Integer department) {
		this.departmentId = department;
	}

	public Integer getQuConfirmed() {
		return this.quConfirmed;
	}

	public void setQuConfirmed(Integer quConfirmed) {
		this.quConfirmed = quConfirmed;
	}

	public String getSender() {
		return this.sender;
	}

	public void setSender(String sender) {
		this.sender = sender;
	}

	public Integer getMsgtype() {
		return this.msgtype;
	}

	public void setMsgtype(Integer msgtype) {
		this.msgtype = msgtype;
	}

	public String getMsgtitle() {
		return this.msgtitle;
	}

	public void setMsgtitle(String msgtitle) {
		this.msgtitle = msgtitle;
	}

	public String getMsgattachfiles() {
		return this.msgattachfiles;
	}

	public void setMsgattachfiles(String msgattachfiles) {
		this.msgattachfiles = msgattachfiles;
	}

	public Timestamp getArrivetime() {
		return this.arrivetime;
	}

	public void setArrivetime(Timestamp arrivetime) {
		this.arrivetime = arrivetime;
	}
	
	public Timestamp getCompletetime() {
		return completetime;
	}

	public void setCompletetime(Timestamp completetime) {
		this.completetime = completetime;
	}

	public Integer getMsgstate() {
		return this.msgstate;
	}

	public void setMsgstate(Integer msgstate) {
		this.msgstate = msgstate;
	}

	public String getShiComments() {
		return this.shiComments;
	}

	public void setShiComments(String shiComments) {
		this.shiComments = shiComments;
	}

	public String getQuComments() {
		return this.quComments;
	}

	public void setQuComments(String quComments) {
		this.quComments = quComments;
	}

	public String getJieComments() {
		return this.jieComments;
	}

	public void setJieComments(String jieComments) {
		this.jieComments = jieComments;
	}

	public String getSubmitfiles() {
		return this.submitfiles;
	}

	public void setSubmitfiles(String submitfiles) {
		this.submitfiles = submitfiles;
	}

	public String getFinalcomments() {
		return this.finalcomments;
	}

	public void setFinalcomments(String finalcomments) {
		this.finalcomments = finalcomments;
	}

	public Integer getCompletestate() {
		return this.completestate;
	}

	public void setCompletestate(Integer completestate) {
		this.completestate = completestate;
	}


	public Integer getQuDepartmentId() {
		return quDepartmentId;
	}

	public void setQuDepartmentId(Integer quDepartmentId) {
		this.quDepartmentId = quDepartmentId;
	}

	
	public Mmessage toEntity(){
		Mmessage msg = new Mmessage();
		msg.setId(getId());
	
		msg.setArrivetime(getArrivetime());
		msg.setCompletetime(getCompletetime());
		msg.setCompletestate(getCompletestate());
		msg.setFinalcomments(getFinalcomments());
		msg.setJieComments(getJieComments());
		msg.setQuComments(getQuComments());
		msg.setMsgattachfiles(getMsgattachfiles());		
		msg.setMsgstate(getMsgstate());
		msg.setMsgtitle(getMsgtitle());
		msg.setMsgtype(getMsgtype());
		msg.setQuConfirmed(getQuConfirmed());
		msg.setShiComments(getShiComments());	
		msg.setSubmitfiles(getSubmitfiles());		
		msg.setSender(getSender());
		
		Patrol patrol=null;
		if(getPatrolId()!=null){
			PatrolDao deptDao = new PatrolDao();		
			patrol = deptDao.findById(getPatrolId());
		}		
		msg.setPatrol(patrol);		
		
		
		Subissuetype subissue=null;		
		if(getSubissuetypeId()!=null){
			SubissuetypeDao deptDao = new SubissuetypeDao();		
			subissue = deptDao.findById(getSubissuetypeId());
		}		
		msg.setSubissuetype(subissue);	

		Department parent_dept=null;
		if(getDepartmentId()!=null){
			DepartmentDao deptDao = new DepartmentDao();		
			parent_dept = deptDao.findById(getDepartmentId());
		}		
		msg.setDepartment(parent_dept);

		Department qudept=null;
		if(getQuDepartmentId()!=null){
			DepartmentDao deptDao = new DepartmentDao();		
			qudept = deptDao.findById(getQuDepartmentId());
		}		
		msg.setQudepartment(qudept);
		
		Department jiedao=null;
		if(getProblemJDId()!=null){
			DepartmentDao deptDao = new DepartmentDao();		
			jiedao = deptDao.findById(getProblemJDId());
		}		
		msg.setProblemJD(jiedao);		
		return msg;
	}

	@Override
	public String getName() {
		// TODO Auto-generated method stub
		return this.getMsgtitle();
	}
}